package com.zxm.ssm.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zxm.ssm.entity.Product;
import com.zxm.ssm.mapper.ProductMapper;
import com.zxm.ssm.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductServiceImpl implements ProductService {
    @Autowired
    private ProductMapper productMapper;

    @Override
    public PageInfo<Product> findAllProducts(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Product> products = productMapper.findAll();
        PageInfo<Product> pageInfo = new PageInfo<>(products);
        return pageInfo;
    }

    @Override
    public Product findProductById(int id) {
        return productMapper.findById(id);
    }

    @Override
    public int deleteProduct(int id) {
        return productMapper.deleteProduct(id);
    }

    @Override
    public int updateProduct(Product product) {
        return productMapper.updateProduct(product);
    }

    @Override
    public int insertProduct(Product product) {
        return productMapper.insertProduct(product);
    }


    /*舒龙*/
    @Override
    public PageInfo<Product> findAllProduct(int pagNum, int pagSize) {
        PageHelper.startPage(pagNum, pagSize);
        PageInfo<Product> pageInfo = new PageInfo<Product>(productMapper.findAll());
        return pageInfo;
    }


}
